package plus.xj17520.org.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import plus.xj17520.basic.domain.AjaxResult;
import plus.xj17520.org.mapper.UserMapper;
import plus.xj17520.org.service.IUserService;

import java.util.regex.Pattern;

/**
 * @projectName: pethome_xj
 * @package: plus.xj17520.org.service.impl
 * @className: UserServiceImpl
 * @author: XiaoJue
 * @description: TODO
 * @date: 2022/4/2 11:36
 * @version: 1.0
 */
@Service
public class UserServiceImpl implements IUserService {
    @Autowired
    private UserMapper userMapper;

    @Override
    public void sendCode() {

    }

    @Override
    public AjaxResult findPhone(String phoneNum) {
        Pattern pattern = Pattern.compile("^[1]\\d{10}$");
        boolean matches = pattern.matcher(phoneNum).matches();
        if (!matches){
            return AjaxResult.setMsg("手机号异常");
        }
        userMapper.findPhone(phoneNum);
        return AjaxResult.me();
    }
}
